<?php
/**
 * Created by PhpStorm.
 * User: cc
 * Date: 2024/5/23
 * Time: 10:19
 */

namespace app\zyhsapi\model\comment;

use app\zyhsapi\model\BaseCacheZyhs;
use XznsTools\cache\zyhs\CacheManageZyhs;

class ZyhsNoComment extends BaseCacheZyhs
{
    protected $table = 'good_wechat.zyhs_no_comment';

    protected $cacheModel = 'zyhs.no_comment';

    /**
     * 获取禁言列表
     * @param int $type
     * @return array|mixed
     * @throws \Exception
     */
    public function getNoCommentList(int $type)
    {
        $ids = CacheManageZyhs::getInstance()->setCacheConfig($this->cacheModel, $type)->setSort('desc')->ZsGetIocData('list', function () use ($type)
        {
            //活动只有折扣类型
            $where = ['type' => $type];
            try
            {
                $ids = $this->where($where)->order('id', 'DESC')->column('uid', 'id');
            }
            catch (\Exception $e)
            {
                $ids = [];
            }
            return $ids;
        }, true);

        foreach ($ids as $key => $val)
        {
            $ids[(int)$key] = (int)$val;
        }
        return $ids;
    }
}
